package ch.mustaffah.aoide.model;

public class ScorePattern {
	
	private Score[] pattern;

	private ScorePattern(){
	}
	
	public ScorePattern(Score[] pattern){
		//sanity check
		if(pattern != null && pattern.length == 12){
			for(int i=0;i<pattern.length;i++){
				//auto fill null
				if(pattern[i]==null){
					//for null add empty Score at correct position.
					pattern[i]=new Score(i,0,false);
				}
				//set correct position
				pattern[i].setPosition(i);
			}
			this.pattern=pattern;
		}else{
			getPattern();
		}
		
	}

	public Score[] getPattern() {
		if(this.pattern==null){
			this.pattern=new Score[12];
			for(int i=0;i<pattern.length;i++){
				//autorepair
				if(pattern[i]==null){
					//for null add empty Score at correct position.
					pattern[i]=new Score(i,0,false);
				}
			}	
		}
		return this.pattern;
	}

}
